You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
532 B
13 lines
532 B
import { toggleFavorite } from "../../../service/favorite";
|
|
import { requireUser } from "#server/utils/context";
|
|
|
|
export default defineWrappedResponseHandler(async (event) => {
|
|
const user = await requireUser(event);
|
|
const idParam = getRouterParam(event, "id");
|
|
if (!idParam) return R.throwError(400, "缺少卡片 ID", null);
|
|
const cardId = parseInt(idParam);
|
|
if (isNaN(cardId)) return R.throwError(400, "无效的卡片 ID", null);
|
|
|
|
const result = await toggleFavorite(user.id, cardId);
|
|
return R.success(result);
|
|
});
|
|
|